using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using Xeml.Document.Contracts;
using Xeml.Document;
using System.Diagnostics;

namespace Xeml.Visualization.Controls
{
    public partial class AdvancedXemlViewer : UserControl
    {



        public XemlViewer XemlViewer
        {
            get { return xemlViewer; }
        }


        /// <summary>
        /// The current xeml document.
        /// </summary>
        public IDocument XemlDoc
        {
            get { return this.xemlViewer.XemlDoc; }
            set 
            { 
                this.xemlViewer.XemlDoc = value; 
            }
        }

        /// <summary>
        /// The standard constructor.
        /// </summary>
        public AdvancedXemlViewer()
        {
            InitializeComponent();
            //this.xemlViewer.Mtls = this.mtls;

            this.mtls.Scroll += new ScrollEventHandler(OnPanel2Scroll);
            this.xemlViewer.Scroll += new ScrollEventHandler(OnXemlViewerScroll);
        }


        /// <summary>
        /// Event handling code for xemlviewer scrolling.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void OnXemlViewerScroll(object sender, ScrollEventArgs e)
        {
            if (e.ScrollOrientation == ScrollOrientation.HorizontalScroll)
            {
                this.mtls.AutoScrollPosition = new Point(e.NewValue, this.mtls.AutoScrollPosition.Y);
            }
        }

        /// <summary>
        /// Event handling code for panel2 scrolling
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void OnPanel2Scroll(object sender, ScrollEventArgs e)
        {
            if (e.ScrollOrientation == ScrollOrientation.HorizontalScroll)
            {
                xemlViewer.AutoScrollPosition = new Point(e.NewValue, xemlViewer.AutoScrollPosition.Y);
            }
        }

        protected override bool IsInputChar(char charCode)
        {
            Debug.WriteLine("AdvancedXemlViewer: IsInputKey ? " + charCode);
            return base.IsInputChar(charCode);
        }

    }
}
